package lnkwe.core.db;

import com.alibaba.fastjson.JSONObject;

import java.io.Serializable;
import java.util.List;

public class QueryPage<T> implements Serializable {
    private int curPage;
    private int rowCount;
    private int rowSize;
    private int totalSize;

    private List<T> list;

    public int getCurPage() {
        return curPage;
    }

    public void setCurPage(int curPage) {
        this.curPage = curPage;
    }

    public int getRowCount() {
        return rowCount;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
    }

    public int getRowSize() {
        return rowSize;
    }

    public void setRowSize(int rowSize) {
        this.rowSize = rowSize;
    }

    public int getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(int totalSize) {
        this.totalSize = totalSize;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public JSONObject toJSON() {
        JSONObject dataJSON = new JSONObject();
        dataJSON.put("list", this.list);
        dataJSON.put("curPage", this.getCurPage());
        dataJSON.put("count", this.getRowCount());
        dataJSON.put("totalSize", this.getTotalSize());
        return dataJSON;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("PageInfo{");
        sb.append("pageNum=").append(this.getCurPage());
        sb.append(", pageSize=").append(this.getRowSize());
        return sb.toString();
    }
}
